<?php

  require_once "JooS/UCS2.php";

  abstract class JooS_UCS2_ASCII extends JooS_UCS2 {
    abstract public function getCharTable();

    public function convertString($str) {
      $Chars = $this->getCharTable();

      if (is_array($Chars)) {
        if (sizeof($Chars) == 128) {
          for ($i=128; $i<=255; $i++)
            if (!isset($Chars[$i-128]))
              self::throwException(__CLASS__.". Character table: missed simbol #".($i-128));
            elseif (!is_string($Chars[$i-128]))
              self::throwException(__CLASS__.". Character table: simbol #".($i-128)." must be a string");
            else
              $str = str_replace(chr($i), $Chars[$i-128], $str);
        }
        elseif (sizeof($Chars))
          self::throwException("Character table must be empty array or array [0..127]");
      } 
      else
        self::throwException("Character table must be an array");

      return $str;
    }
  }


?>